﻿<Window 
  x:Class="Sample4.CustomTypeEditors.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:pg="http://schemas.denisvuyka.wordpress.com/wpfpropertygrid"    
  xmlns:local="clr-namespace:Sample4.CustomTypeEditors"  
  xmlns:core="clr-namespace:System;assembly=mscorlib"
  xmlns:markup="clr-namespace:System.Windows.Markup;assembly=PresentationCore"
  
  Title="Sample4. Custom Type Editors." Height="600" Width="800">
  
  <Window.Resources>    
    <BooleanToVisibilityConverter x:Key="btvc"/>
  </Window.Resources>
  
    <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition />
      <ColumnDefinition />
    </Grid.ColumnDefinitions>

    <StackPanel x:Name="objectPanel" Grid.Column="0" Margin="0,10,10,0">      
      <TextBlock TextWrapping="Wrap">
        This sample demonstrates the possibilities of specifying custom type editors based on dialogs.        
      </TextBlock>
      <Button x:Name="btnTest" Content="Toggle 'Login' Visibility" Click="btnTest_Click" Width="200"/>
      <CheckBox x:Name="toggleGrid" Content="Toggle Properties" IsChecked="True"/>
      <CheckBox x:Name="toggleSearchBox" Content="Toggle Search Box" IsChecked="True" Visibility="{Binding ElementName=toggleGrid, Path=IsChecked, Converter={StaticResource btvc}, Mode=OneWay}"/>
      <Button x:Name="btnSwitchObjects" Content="Select Single" Click="btnSwitchObjects_Click"/>
      <Button x:Name="btnSelectMultiple" Content="Select Multiple" Click="btnSelectMultiple_Click"/>
    </StackPanel>

    <GridSplitter Width="2" />

    <pg:PropertyGrid x:Name="propertyGrid" 
                     Grid.Column="1"              
                     PropertyDisplayMode="All"
                     Background="Transparent"
                     ShowAttachedProperties="False"
                     ShowReadOnlyProperties="False"                     
                     PropertyFilterVisibility="{Binding ElementName=toggleSearchBox, Path=IsChecked, Converter={StaticResource btvc}, Mode=TwoWay}"                     
                     Visibility="{Binding ElementName=toggleGrid, Path=IsChecked, Converter={StaticResource btvc}, Mode=TwoWay}">
      <!--<pg:PropertyGrid.Resources>
        <ResourceDictionary Source="/Orbifold.WpfPropertyGrid.Themes;component/Kaxaml/Theme.xaml"/>
      </pg:PropertyGrid.Resources>-->
      <!--<pg:PropertyGrid.Resources>
        <ResourceDictionary>
          <ResourceDictionary.MergedDictionaries>
            <themes:KaxamlTheme/>
          </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>        
      </pg:PropertyGrid.Resources>-->
      
      <pg:PropertyGrid.Editors>
        
        <pg:TypeEditor EditedType="{x:Type core:DateTime}" InlineTemplate="{StaticResource MyDateEditorInlineTemplate}"/>        
        <pg:TypeEditor EditedType="{x:Type Point}" InlineTemplate="{StaticResource MyPointInlineEditorTemplate}"/>
        <pg:TypeEditor EditedType="{x:Type markup:XmlLanguage}" InlineTemplate="{x:Static local:LocalResources.XmlLanguageEditorKey}"/>
        
        <pg:PropertyEditor DeclaringType="{x:Type local:BusinessObject}" PropertyName="Percentage" InlineTemplate="{x:Static local:LocalResources.PercentEditorKey}"/>
        <pg:PropertyEditor DeclaringType="{x:Type local:BusinessObject}" PropertyName="Name" InlineTemplate="{StaticResource MyCustomExtendedTemplate_Inline}" ExtendedTemplate="{StaticResource MyCustomExtendedTemplate_Extended}"/>
        <pg:PropertyEditor DeclaringType="{x:Type local:BusinessObject}" PropertyName="Range" InlineTemplate="{x:Static pg:EditorKeys.SliderEditorKey}"/>
        <pg:PropertyEditor DeclaringType="{x:Type local:BusinessObject}" PropertyName="Password" InlineTemplate="{x:Static pg:EditorKeys.PasswordEditorKey}"/>
        <pg:PropertyEditor DeclaringType="{x:Type local:BusinessObject}" PropertyName="DoubleBlend" InlineTemplate="{x:Static pg:EditorKeys.DoubleEditorKey}"/>
        
        <pg:CategoryEditor DeclaringType="{x:Type local:BusinessObject}" CategoryName="Text" InlineTemplate="{StaticResource TextCategoryEditor}"/>
        
      </pg:PropertyGrid.Editors>
      
      <pg:PropertyGrid.Layout>
        <!-- USE DEFAULT ALPHABETICAL LAYOUT -->
        <!--<pg:AlphabeticalLayout/>-->

        <!-- USE DEFAULT CATEGORIZED LAYOUT -->
        <!--<pg:CategorizedLayout/>-->

        <!-- #1 USE DEFAULT TABBED LAYOUT -->
        <pg:TabbedLayout>
          
          <!-- #1.1: Default layout usage -->
          <!-- 
          <pg:TabbedLayoutItem CanClose="true" Header="Categorized">
            <pg:CategorizedLayout />
          </pg:TabbedLayoutItem>
          <pg:TabbedLayoutItem CanClose="true" Header="Alphabetical">
            <pg:AlphabeticalLayout />
          </pg:TabbedLayoutItem>
          -->

          <!-- #1.2: Alternative layout usage (any Control being powered by attached properties) -->          
          <pg:CategorizedLayout pg:TabbedLayout.CanClose="False" pg:TabbedLayout.Header="Categorized"/>
          <pg:AlphabeticalLayout pg:TabbedLayout.CanClose="False" pg:TabbedLayout.Header="Alphabetical"/>          
          
        </pg:TabbedLayout>

        <!-- #2 USE CUSTOM TABBED LAYOUT. EACH CATEGORY GOES TO A SEPARATE TAB -->
        <!--
        <pg:TabbedLayout ItemsSource="{Binding Categories}" ItemHeaderProperty="CategoryName">
          <pg:TabbedLayout.Resources>
            <DataTemplate DataType="{x:Type pg:CategoryItem}">
              <pg:PropertyItemsLayout ItemsSource="{Binding Properties}"/>
            </DataTemplate>
          </pg:TabbedLayout.Resources>
        </pg:TabbedLayout>
        -->
      </pg:PropertyGrid.Layout>
    </pg:PropertyGrid>
  </Grid>
</Window>
